package com.cn.demo.controller;

import com.cn.demo.entity.Curriculum;
import com.cn.demo.service.CurriculumService;
import com.cn.demo.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
;import java.util.Date;

@RestController
@RequestMapping("/curriculum")
public class CurriculumController {
    @Autowired
    private CurriculumService curriculumService;

    @PostMapping(value = "")
    public Result add(@RequestBody Curriculum curriculum) {
        return curriculumService.add(curriculum);
    }

    @GetMapping(value = "")
    public Result get(@RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "limit", defaultValue = "5") Integer limit,
                      @RequestParam(value = "curriculumId", required = false) String curriculumId,
                      @RequestParam(value = "curriculumName", required = false) String curriculumName,
                      @RequestParam(value = "content", required = false) String content,
                      @RequestParam(value = "classHour", required = false) String classHour,
                      @RequestParam(value = "startDate", required = false) Date startDate,
                      @RequestParam(value = "endDate", required = false) Date endDate,
                      @RequestParam(value = "curriculumDesignId", required = false) String curriculumDesignId,
                      @RequestParam(value = "curriculumExperimentId", required = false) String curriculumExperimentId,
                      @RequestParam(value = "curriculumInternshipId", required = false) String curriculumInternshipId
    ) {
        Curriculum curriculum = new Curriculum();
        return curriculumService.get(page, limit, curriculum);
    }
}